home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 145 / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin / games / spassion / source.lzh / SOURCE / FuncEnemy / BOSSARM.C < prev    next >
Text File  |  2000-03-21  |  8KB  |  300 lines

  1. /*
  2. #include <stdio.h>
  3. #include <iocslib.h>
  4. */
  5. /* ボスの腕 */
  6. #include <xsp2lib.h>
  7. #include "../SPASSION.H"
  8. #include "../player.h"
  9. #include "../enemy.h"
  10. #include "../eshot.h"
  11. #include "../effect.h"
  12. #include "../priority.h"
  13. #include "../sound.h"
  14. #include "../entry.h"
  15. #include "../SUB.H"
  16. #ifndef NULL
  17. #define NULL ((void *) 0)
  18. #endif
  19.  
  20. #define P_X    (*((short *) (&player[0].lx)))    /*lxの上位ワード*/
  21. #define P_Y    (*((short *) (&player[0].ly)))    /*lyの上位ワード*/
  22.  
  23. #define PALET_MAIN    0x0700
  24.  
  25. static short MoveEnemyBossArm(ENEMY *);
  26. static short MoveEnemyBossArm1(ENEMY *);
  27. /*static void TiniEnemyBossArm(ENEMY *);*/
  28. static HIT_XY4    hit_head_p[]={0-8-PLAYER_HIT_X,0-8-PLAYER_HIT_Y,0+8+PLAYER_HIT_X,0+8+PLAYER_HIT_Y};
  29. static HIT_XY4    hit_head_o[]={0-8-OPTION_HIT_X,0-8-OPTION_HIT_Y,0+8+OPTION_HIT_X,0+8+OPTION_HIT_Y};
  30. static HIT_XY4    hit_head_s[]={0-8,0-8,0+8,0+8};
  31.  
  32. static HIT_XY4    hit_body_p[]={
  33.     0-10-PLAYER_HIT_X,0-10-PLAYER_HIT_Y,0+10+PLAYER_HIT_X,0+10+PLAYER_HIT_Y
  34. };
  35. static HIT_XY4    hit_body_s[]={
  36.     0-10,0-10,0+10,0+10
  37. };
  38. extern HIT_XY4    nohit;
  39.  
  40.  
  41. void InitEnemyBossArmHit( void )
  42. {
  43. }
  44.  
  45. void InitEnemyBossArm1Hit( void )
  46. {
  47. }
  48.  
  49. void InitEnemyBossArm(ENEMY *ene)
  50. {
  51.     short    pri[2]={PRIORITY_BOSS_PARTS_L,PRIORITY_BOSS_PARTS};
  52.  
  53.     ene->info = PALET_MAIN | pri[ene->arg>>12];
  54.     ene->vx             = 0;
  55.     if( !(ene->arg&0x0F00) ){
  56.         ene->vy         = -65536/2;
  57.         ene->angle     = 0;
  58.     }else{
  59.         ene->vy         = 65536/2;
  60.         ene->angle     = 128;
  61.     }
  62.     ene->hit_p[0]     = &hit_body_p[0];ene->hit_p[1]=NULL;
  63.     ene->hit_o[0]     = &nohit        ;ene->hit_o[1]=NULL;
  64.     ene->hit_s[0]     = &hit_body_s[0];ene->hit_s[1]=NULL;
  65.     ene->pt             = obj_dragon+160;
  66.     ene->work         = 0;
  67.     ene->no_dead     = 0;
  68.     ene->func_enemy_move = MoveEnemyBossArm;
  69. /*    ene->func_enemy_tini = TiniEnemyBossArm;*/
  70.  
  71.     ene->arg--;
  72.     if( (char)ene->arg < 0 )
  73.         ene->arg++;
  74.     if( (char)ene->arg )
  75.         ene->child=MakeEnemy(ENEMY_BOSSARM , ene->lx>>16, ene->ly>>16,ene->arg,  ene);
  76.     else
  77.         ene->child=MakeEnemy(ENEMY_BOSSARM1, ene->lx>>16, ene->ly>>16,ene->arg,  ene);
  78. }
  79.  
  80. /* 腕の先端 */
  81. void InitEnemyBossArm1(ENEMY *ene)
  82. {
  83.     ene->pt         = obj_dragon;
  84.     ene->vx         = 0;
  85.     if( !(ene->arg&0x0F00) ){
  86.         ene->vy         = -65536/2;
  87.         ene->angle     = 192;
  88.     }else{
  89.         ene->vy         = 65536/2;
  90.         ene->angle     = 192;
  91.     }
  92.     ene->hit_p[0] = &nohit;
  93.     ene->hit_o[0] = &nohit;
  94.     ene->hit_s[0] = &nohit;
  95.     ene->hp        = 200;
  96.     ene->work    = 0;
  97.     ene->func_enemy_move = MoveEnemyBossArm1;
  98. /*    ene->func_enemy_tini = TiniEnemyBossArm;*/
  99. }
  100.  
  101. static void GetAngle( ENEMY *ene )
  102. {
  103.     unsigned char tmp,p_num=0;
  104.  
  105.     if( play_mode == MODE_2P && (ene->arg&0x0F00) )
  106.         p_num=1;
  107.  
  108.     if( ++ene->work2 > 4 ){                /* 4 回ごとに向き修正 */
  109.         tmp = calc_direction( ENE_X, ENE_Y, player[p_num].x,player[p_num].y );
  110.  
  111.         tmp = (tmp - ene->angle) & (256 - 1);
  112.         if( tmp ){
  113.             if (tmp > 127) ene->angle-=2;
  114.             else ene->angle+=2;
  115.             ene->angle &= 256 - 1;
  116.         }
  117.  
  118.         ene->work2=0;
  119.     }
  120. }
  121.  
  122. /* 腕 */
  123. static short MoveEnemyBossArm( ENEMY *ene )
  124. {
  125.     int        t;
  126.  
  127.     if( ene->child_death ){
  128.         if( ene->child_kill ){
  129.             ene->child->child_kill=1;
  130.             return (0);        /* 消去 */
  131.         }else
  132.             return 1;
  133.     }
  134.  
  135.     /* 速度を足して上位ワード(固定整数部)だけ取り出す */
  136.     ene->x = (ene->lx += ene->vx) >> 16;
  137.     ene->y = (ene->ly += ene->vy) >> 16;
  138.  
  139.     switch (ene->state){
  140.     case 0:        /* 縦方向に伸びる */
  141.         t=ene->parent->ly-ene->ly;
  142.         if(t<0)t*=-1;
  143.         if( t > vy_tbl[30][128] ){
  144.             ene->vy=0;
  145.             ene->state++;
  146.         }
  147.         ene->lx=ene->parent->lx;
  148.         break;
  149.     case 1:        /* 縦方向に伸びる */
  150.         if( ene->child->state==2 )    /* 子オブジェクトが伸びきるまで待つ */
  151.             ene->state++;
  152.         ene->lx=ene->parent->lx;
  153.         break;
  154.     case 2:
  155.         GetAngle(ene);
  156.             ene->lx=ene->parent->lx+vx_tbl[30][ene->angle];
  157.             ene->ly=ene->parent->ly+vy_tbl[30][ene->angle];
  158.         break;
  159.     case 3:
  160.         break;
  161.     }
  162.  
  163.     if( ene->child->child_death ){
  164.         if( ene->work++>20 ){
  165.             MakeEffect(EFFECT_HAHENMINI, 0, ene->x, ene->y);
  166.             ene->child_death=1;
  167.             ene->hit_p[0]=NULL;
  168.         }
  169.     }
  170.     xobj_set_st(ene);
  171.  
  172.     return(1);
  173. }
  174.  
  175. /* 腕の先端 */
  176. static short MoveEnemyBossArm1( ENEMY *ene )
  177. {
  178.     int        t;
  179.     short    speed;
  180.     short    pri[2]={PRIORITY_BOSS_PARTS_L,PRIORITY_BOSS_PARTS};
  181.     short Wait( ENEMY *ene, short time );
  182.  
  183.     if( ene->child_death ){
  184.         if( ene->child_kill ){
  185.             return (0);        /* 消去 */
  186.         }else
  187.             return 1;
  188.     }
  189.  
  190.     /* 速度を足して上位ワード(固定整数部)だけ取り出す */
  191.     ene->x = (ene->lx += ene->vx) >> 16;
  192.     ene->y = (ene->ly += ene->vy) >> 16;
  193.  
  194.     GetAngle(ene);
  195.     ene->pt = obj_dragon + (ene->angle >> 3);
  196.     if( ene->arg&0x0F00 )
  197.         ene->pt += 64;
  198.  
  199.     switch (ene->state){
  200.     case 0:        /* 縦方向に伸びる */
  201.         t=ene->parent->ly-ene->ly;
  202.         if(t<0)t*=-1;
  203.         if( t > vy_tbl[30][128] ){
  204.             ene->vy=0;
  205.             ene->hit_p[0] = &hit_head_p[0];
  206.             ene->hit_o[0] = &hit_head_o[0];
  207.             ene->hit_s[0] = &hit_head_s[0];
  208.             ene->state+=2;
  209.         }
  210.         ene->lx=ene->parent->lx;
  211.         break;
  212.     case 2:        /* しばらく自機を追いかける */
  213.         ene->lx=ene->parent->lx+vx_tbl[30][ene->parent->angle];
  214.         ene->ly=ene->parent->ly+vy_tbl[30][ene->parent->angle];
  215.         if( Wait( ene, 240) )ene->state++;
  216.         break;
  217.     case 3:        /* 吸い込む */
  218.         if( !Wait( ene, 240) ){
  219.             ene->pt += 32;
  220.             ene->lx=ene->parent->lx+vx_tbl[30][ene->parent->angle];
  221.             ene->ly=ene->parent->ly+vy_tbl[30][ene->parent->angle];
  222.             if( ene->count < 48 ){
  223.                 gr1_vx-=(32768*2/48);
  224.                 gr2_vx-=(21845*2/48);
  225.                 speed=(ene->work++)/16;
  226.             }else if( ene->count < 256-48 ){
  227.                 speed=ene->work/16;
  228.             }else{
  229.                 gr1_vx+=(32768*2/48);
  230.                 gr2_vx+=(21845*2/48);
  231.                 speed=(ene->work--)/16;
  232.                 if(speed<0)speed=0;
  233.             }
  234.             player[0].lx-=vx_tbl[speed][calc_direction( ENE_X, ENE_Y, P_X, P_Y )];
  235.             player[0].ly-=vy_tbl[speed][calc_direction( ENE_X, ENE_Y, P_X, P_Y )];
  236.             if( (*((short *)(&player[0].lx))) < PLAYER_MIN_X )
  237.                 player[0].lx = PLAYER_MIN_X<<16;
  238.             if( (*((short *)(&player[0].lx))) > PLAYER_MAX_X )
  239.                 player[0].lx = PLAYER_MAX_X<<16;
  240.             if( (*((short *)(&player[0].ly))) < PLAYER_MIN_Y )
  241.                 player[0].ly = PLAYER_MIN_Y<<16;
  242.             if( (*((short *)(&player[0].ly))) > PLAYER_MAX_Y )
  243.                 player[0].ly = PLAYER_MAX_Y<<16;
  244.  
  245.             player[0].x = (*((short *)(&player[0].lx)));    /*lxの上位ワード*/
  246.             player[0].y = (*((short *)(&player[0].ly)));    /*lyの上位ワード*/
  247.             if( play_mode == MODE_2P ){
  248.                 player[1].lx-=vx_tbl[6][calc_direction( ENE_X, ENE_Y, P_X, P_Y )];
  249.                 player[1].ly-=vy_tbl[6][calc_direction( ENE_X, ENE_Y, P_X, P_Y )];
  250.                 if( (*((short *)(&player[1].lx))) < PLAYER_MIN_X )
  251.                     player[1].lx = PLAYER_MIN_X<<16;
  252.                 if( (*((short *)(&player[1].lx))) > PLAYER_MAX_X )
  253.                     player[1].lx = PLAYER_MAX_X<<16;
  254.                 if( (*((short *)(&player[1].ly))) < PLAYER_MIN_Y )
  255.                     player[1].ly = PLAYER_MIN_Y<<16;
  256.                 if( (*((short *)(&player[1].ly))) > PLAYER_MAX_Y )
  257.                 player[1].ly = PLAYER_MAX_Y<<16;
  258.  
  259.                 player[1].x = (*((short *)(&player[1].lx)));    /*lxの上位ワード*/
  260.                 player[1].y = (*((short *)(&player[1].ly)));    /*lyの上位ワード*/
  261.             }
  262.             SetSE(SE_VACUUM);    /* 吸い込み音 */
  263.         }else{
  264.             ene->state=2;
  265.             ene->work=0;
  266.             gr1_vx=32768;
  267.             gr2_vx=21845;
  268.         }
  269.     }
  270.  
  271.     /* ダメージを受けた時の処理 */
  272.     if(ene->damage){
  273.         SetSE(SE_DAMAGE);    /* 効果音 */
  274.         ene->info = PALET_DAMAGE | pri[ene->arg>>12];
  275.         /* スクロール値が戻っているときに破壊 */
  276.         if( (ene->hp -= ene->damage) <= 0 && ene->state==2 ){
  277.             MakeEffect(EFFECT_EXPL, 0, ene->x, ene->y);
  278.             SetSE(SE_EXPL_MBOSS);    /* 爆発音 */
  279.             if(disp_level == DISP_LEVEL_HIGH)
  280.                 MakeEffect (EFFECT_HAHENMINI, 0, ene->x, ene->y);
  281.             if(!eshot_erase)
  282.                 eshot_erase = ESHOT_ERASE;        /* 弾消し */
  283.             ene->player->score += 10;
  284.             ene->hit_p[0]=NULL;
  285.             ene->child_death = 1;
  286.         }
  287.         ene->damage = 0;
  288.     }else
  289.         ene->info = PALET_MAIN | pri[ene->arg>>12];
  290.  
  291.     xobj_set_st(ene);
  292.     return 1;
  293. }
  294.  
  295. /*
  296. static void TiniEnemyBossArm(ENEMY * p)
  297. {
  298. }
  299. */
  300.